#include <iostream>
#include <cmath>

using namespace std;

int T;
long long n, h;
long double r;

struct point
{
    long long x;
    long long y;
    long long z;
} p[1010];

long long fa[1010];
long long Rank[1010];

void init()
{
    for (long long i = 1; i <= n; i++)
    {
        fa[i] = i;
        Rank[i] = 0;
    }
}

long long find(int x)
{
    if (x == fa[x])
        return x;
    else
    {
        fa[x] = find(fa[x]);
        return fa[x];
    }
}

void merge(long long i, long long j)
{
    long long x = find(i);
    long long y = find(j);
    if (Rank[x] <= Rank[y])
    { //小向大合并
        fa[x] = y;
    }
    else
        fa[y] = x;
    if (Rank[x] == Rank[y] && x != y)
    {
        Rank[y]++;
    }
}

long double dis(const point &A, const point &B)
{
    long double d = sqrt((A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y) + (A.z - B.z) * (A.z - B.z));
    return d;
}

int main()
{
    cin >> T;
    while (T--)
    {
        cin >> n >> h >> r;

        init(); //初始化

        fa[1002] = 1002; //底部
        fa[1003] = 1003; //顶部

        for (int i = 1; i <= n; i++)
        {
            cin >> p[i].x >> p[i].y >> p[i].z;
        }
        for (int i = 1; i <= n; i++)
        {
            if (p[i].z <= r)
                merge(i, 1002); //合并底部
            if (p[i].z + r >= h)
                merge(i, 1003); //合并顶部
        }
        for (int i = 1; i <= n; i++)
        {
            for (int j = i + 1; j <= n; j++)
            {
                if (dis(p[i], p[j]) <= r * 2)
                {
                    merge(i, j); //两两合并
                }
            }
        }

        if (find(1002) == find(1003))
        {
            cout << "Yes" << endl;
        }
        else
            cout << "No" << endl;
    }
}